package com.partner.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.partner.domain.University;
import com.partner.domain.ZhuanYe;
import com.partner.util.DBUtil;

//大学和专业的一些操作
public class UniversityAndZhuanyeDao {
	QueryRunner queryRunner_auto = new QueryRunner(DBUtil.getDataSource());
	QueryRunner queryRunner_self = new QueryRunner();
	//查询大学
	public List<University> selectUniversity(){
		List<University> universities = new ArrayList<University>();
		String sql = "select * from university";
		try {
			List<University> temp = queryRunner_auto.query(sql, new BeanListHandler<University>(University.class));
			if(temp!=null){
				universities = temp;
				return universities;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return universities;
		
	}
	
	//查询专业
	public List<ZhuanYe> selectZhuanye(){
		List<ZhuanYe> zhuanyes = new ArrayList<ZhuanYe>();
		String sql = "select * from zhuanye";
		try {
			List<ZhuanYe> temp  = queryRunner_auto.query(sql, new BeanListHandler<ZhuanYe>(ZhuanYe.class));
			if(temp!=null){
				zhuanyes = temp;
				return zhuanyes;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return zhuanyes;
	}
}
